/**
 * Copyright &copy; 2013-2015 山东易科德软件有限公司   All rights reserved.
 */
package cn.net.ecode.modules.sys.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.net.ecode.common.persistence.Page;
import cn.net.ecode.common.service.CrudService;
import cn.net.ecode.modules.sys.dao.UserDictTypeDao;
import cn.net.ecode.modules.sys.entity.UserDict;
import cn.net.ecode.modules.sys.entity.UserDictType;
import cn.net.ecode.modules.sys.utils.UserDictUtils;

/**
 * 用户字典类型管理Service
 * @author ThinkGem
 * @version 2015-07-27
 */
@Service
@Transactional(readOnly = true)
public class UserDictTypeService extends CrudService<UserDictTypeDao, UserDictType> {

	@Autowired
	private UserDictService userDictService;
	
	/**
	 * 获取单条数据
	 * @param userDictType
	 * @return
	 */
	public UserDictType get(UserDictType userDictType) {
		return super.get(userDictType);
	}
	
	/**
	 * 查询列表数据
	 * @param userDictType
	 * @return
	 */
	public List<UserDictType> findList(UserDictType userDictType) {
		return super.findList(userDictType);
	}
	
	/**
	 * 查询分页数据
	 * @param page 分页对象
	 * @param userDictType
	 * @return
	 */
	public Page<UserDictType> findPage(Page<UserDictType> page, UserDictType userDictType) {
		return super.findPage(page, userDictType);
	}
	
	/**
	 * 保存数据（插入或更新）
	 * @param userDictType
	 */
	@Transactional(readOnly = false)
	public void save(UserDictType userDictType) {
		super.save(userDictType);
		UserDictUtils.clearUserDictCache();
	}
	
	/**
	 * 删除数据
	 * @param userDictType
	 */
	@Transactional(readOnly = false)
	public void delete(UserDictType userDictType) {
		super.delete(userDictType);
		UserDict userDict = new UserDict();
		userDict.setDictTypeCode(userDictType.getDictTypeCode());
		userDictService.deleteByUserDictType(userDict);
	}
	
}